package algorithm.distance;

import java.util.ArrayList;
import java.util.List;

import de.gugubarra.core.nop.Nop;
import de.gugubarra.core.nop.Topic;

public class DistanceFunction {
	private static  Nop nopX;
	private static Nop nopY;
	private static double distance;

	public static void setNopAndTopic(Nop x, Nop y, List<Topic> topicList) {
		nopX = x;
		nopY = y;
	}

	public static double getDistance(Nop x, Nop y, List<Topic> topicList) {
		setNopAndTopic(x, y, topicList);
		distance = 0;
		for (int i = 0; i < topicList.size(); i++) {
			Topic aTopic = topicList.get(i);
			double xValue = nopX.getTopicWeight(aTopic);
			double yValue = nopY.getTopicWeight(aTopic);
			//System.out.println(xValue + " : " +yValue);
			distance += (xValue - yValue) * (xValue - yValue);
			
		}
		distance = Math.sqrt(distance);
		
		return distance;
	}
}
